package temp;
import java.sql.*;

public class Test_Call_Procedure {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws ClassNotFoundException, SQLException {
		Class.forName("com.mysql.jdbc.Driver");
		
		Connection conn = DriverManager.getConnection("jdbc:mysql://localhost/sakila?user=root&password=");
		
		DatabaseMetaData dbmd = conn.getMetaData();
		
		ResultSet cats = dbmd.getCatalogs();
		
		while(cats.next())
			System.out.println(cats.getString(1));

		//System.exit(0);
		
		CallableStatement cst = conn.prepareCall("call findFilms(?,?,?)");
		
		cst.setInt(1, 23);
		cst.setInt(2, 32);

		boolean resultType = cst.execute();
		
		ResultSet rs = null;
		if(resultType)
		{
			rs = cst.getResultSet();
			while(rs.next()) {
				System.out.println(rs.getString("title"));
			}
		}
		
		if(cst.getMoreResults()){
			rs = cst.getResultSet();
			while(rs.next()) {
				System.out.println(rs.getString("title"));
			}
		}
		
		System.out.println(cst.getInt(3));
			
	}

}
